<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
    <!--这个方法不加括号，把子组件传来的数据传到父组件对应的处理方法里面 -->
        <zicpn @zidingyishijian='jieshou'></zicpn>
        <h5>{{message}}</h5>
    </div>
    
    <template id="temp1">
        <div>
            <button @click='fasongshuju'>子组件发送数据</button>
        </div>
    </template>
    <script src="../../vue.js"></script>
    <script>
        let zicpn = {
            name:'soncpn',
            template:'#temp1',
            data() {
                return {
                    sondata: 'hello  i am son cpn'
                }
            },
            methods:{
                fasongshuju(){
                    console.log(this.sondata);
                    this.$emit('zidingyishijian',this.sondata)
                }
            }
        }
        new Vue({
            el:'#app',
            components: {
                zicpn,
            },
            data:{
                message:'default values'
            },
            methods: {
                jieshou(zidata) {
                    this.message =zidata
                }
            },
            
        })
    </script>
</body>
</html>